//
// Created by xbm on 23-3-9.
//

#ifndef WEBSERVER_WORKER_H
#define WEBSERVER_WORKER_H

#include <memory>
#include <condition_variable>
#include <future>
#include "concurrentQueue.h"

using  namespace std;

namespace threadPool {

class Worker {
public:
    using JOB_TYPE = shared_ptr<packaged_task<void()>>;

    void operator()();

    static void commit(JOB_TYPE job);

    static void finish();

    Worker();

    ~Worker();

private:

    static inline util::ConcurrentQueue<JOB_TYPE> jobs_;
    static inline condition_variable cv_;
    static inline bool done_ = false;
};
}

#endif //WEBSERVER_WORKER_H
